package main

import (
	"fmt"
	"sync"
	"time"
)

type visited struct {
	mu      sync.Mutex
	visited map[string]int
}

func (v *visited) visitLink(url string) int {
	v.mu.Lock()
	defer v.mu.Unlock()

	count := v.visited[url]
	count++
	v.visited[url] = count

	return count
}

func main() {
	visited := visited{visited: map[string]int{}}
	go visited.visitLink("www.baidu.com")
	go visited.visitLink("www.baidu.com")
	go visited.visitLink("www.baidu.com")
	go visited.visitLink("www.baidu.com")

	time.Sleep(5 * time.Second)
	fmt.Println(visited.visited)
}
